<template>
    <div class="zs-table-page-container">
        <div class="zs-card-sm zs-space-bottom zs-layout-flex-row zs-layout-justify-between">
            <span>
                <el-input class="zs-select-md zs-space-right-sm" v-model="curInput" placeholder="品牌名称" clearable />
                <el-date-picker class="zs-space-right-sm" v-model="dataTime" type="date" placeholder="日期" :clearable="false" value-format="YYYY-MM-DD"/>
                <el-button class="zs-btn-plain" @click="getData()">
                    查询
                </el-button>
            </span>
        </div>
        <div class="zs-card zs-table-page-content">
            <el-table :data="tableData" class="zs-table-page-main" :stripe="stripe">
                <el-table-column label="序号" width="60" :align="'center'">
                    <template #default="scope">
                        {{ scope.$index + 1 + curPageSize * (currentPage - 1) }}
                    </template>
                </el-table-column>
                <el-table-column prop="brandname" label="品牌" :align="'left'" />
                <el-table-column label="销售额" :align="'right'" >
                    <template #default="scope">
                        {{ toThousands(scope.row.daySales) }}
                    </template>
                </el-table-column>
                <el-table-column label="同比上周" :align="'right'" >
                    <template #default="scope">
                        {{ toThousands(scope.row.daySalesW2w) }}%
                    </template>
                </el-table-column>
                <el-table-column label="同比上月" :align="'right'" >
                    <template #default="scope">
                        {{ toThousands(scope.row.daySalesM2m) }}%
                    </template>
                </el-table-column>
            </el-table>
            <div class="zs-space-top-sm zs-table-page-pagination">
                <el-pagination v-model:currentPage="currentPage" v-model:page-size="curPageSize" :page-sizes="curPageSizes"
                    :small="true" :background="true" layout="total, sizes, prev, pager, next, jumper" :total="total"
                    @size-change="handleSizeChange" @current-change="handleCurrentChange" />
            </div>
        </div>
    </div>
</template>
<script setup>
import detailApi from '@/api/Manage/Business/detailPages'
import { ref } from 'vue'
import { toThousands } from '@/utils/number-util'
import { useRoute } from 'vue-router'
import { useStore } from 'vuex'
let store = useStore()
const stripe = ref(true)
const route = useRoute().query

let biProjectCode = ref(route.biProjectCode)
const dataTime = ref(route.dataTime)
let curInput = ref('')

const curPageSizes = ref(store.state.uiPageSizes)
let curPageSize = ref(store.state.uiPageSizeDefault)
// 分页
let currentPage = ref(1)
const total = ref(0)
const handleSizeChange = (val) => {
    curPageSize.value = val
    getList()
}
const handleCurrentChange = (val) => {
    currentPage.value = val
    getList()
}

const tableData = ref([])
const getList = () => {
    detailApi.queryListByRentNameApi({ biProjectCode: biProjectCode.value, dataTime: dataTime.value, rentName: curInput.value, pageNo: currentPage.value, pageSize: curPageSize.value }).then((res) => {
        if (res.data.code == 200) {
            tableData.value = res.data.data.childList
            total.value = res.data.data.totalCount
        }
    })
}
const getData = () => {
    currentPage.value = 1
    getList()
}
getData()
</script>
  
  
<style scoped lang="scss"></style>